﻿#region

using System;
using System.Windows;
using System.Windows.Browser;
using System.Windows.Controls;
using YouTubePlaylist.Models;

#endregion

namespace YouTubePlaylist.Views
{
    public partial class YouTubeApp
    {
        public YouTubeApp(AppModel viewModel)
        {
            InitializeComponent();

            DataContext = viewModel;

            //HACK: Nested popup in ModalDialog/AutoCompleteTextBox causes "catastrophic failure"
            //http://silverlight.net/forums/t/31701.aspx
            //https://silverlight.net/forums/p/32967/102758.aspx
            //ModalHelper.Popup = Popup; //Previous ModalHelper functionality
        }

        private void OnLinkClicked(object sender, RoutedEventArgs e)
        {
            if (HtmlPage.IsPopupWindowAllowed)
            {
                var btn = sender as Button;
                if (btn != null)
                {
                    //HtmlPopupWindowOptions options = new HtmlPopupWindowOptions() { };
                    switch (btn.Tag as string)
                    {
                        case "forum":
                            HtmlPage.Window.Navigate(new Uri("http://forum.youballer.com/viewforum.php?f=9"), "_blank");
                            //HtmlPage.PopupWindow(new Uri("http://forum.youballer.com/viewforum.php?f=9"), string.Empty, options);
                            break;
                        case "feature":
                            HtmlPage.Window.Navigate(new Uri("http://forum.youballer.com/viewforum.php?f=11"), "_blank");
                            //HtmlPage.PopupWindow(new Uri("http://forum.youballer.com/viewforum.php?f=11"), string.Empty, options);
                            break;
                        case "bug":
                            HtmlPage.Window.Navigate(new Uri("http://forum.youballer.com/viewforum.php?f=10"), "_blank");
                            //HtmlPage.PopupWindow(new Uri("http://forum.youballer.com/viewforum.php?f=10"), string.Empty, options);
                            break;
                    }
                }
            }
        }
    }
}